<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";//http://192.168.1.1:8080/abc/abc.jsp
%>
<base href="<%=basePath%>">
<html lang="zh">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <%--响应式*****--%>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <%--响应式***--%>
    <title>XX医院</title>
    <%--<link rel="stylesheet" href="user/css/bootstrap.css">--%>
    <%--<link rel="stylesheet" type="text/css" href="user/css/default.css">--%>
    <%--<link rel="stylesheet" type="text/css" href="user/css/offcanvas.min.css">--%>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <script type="text/javascript" src="assets/H-ui/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="assets/H-ui/static/h-ui/js/H-ui.js"></script>

    <link href="assets/H-ui/static/h-ui/css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="assets/H-ui/static/h-ui.admin/css/style.css" rel="stylesheet" type="text/css" />
    <link href="assets/H-ui/lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" type="text/css" />

    <link rel="stylesheet" type="text/css" href="assets/css/login/css/style.css" />
    <link rel="stylesheet" type="text/css" href="assets/css/login/css/body.css"/>

</head>

<body>
<input type="hidden" id="TenantId" name="TenantId" value="" />
<div class="header"></div>
<div class="container">
    <section id="content">
        <form action="">
            <h1>登录窗口</h1>
            <div>
                <input type="text" placeholder="用户名" required="" id="account" name="account" />
            </div>
            <div>
                <input type="password" placeholder="密码" required="" id="workPwd" name="workPwd" />
            </div>
            <%--<div id="code">--%>
            <div id="code">
                <input type="text" placeholder="验证码" required="" id="keyCode" name="keyCode" />
            </div>
            <div>
                <img src="imageAction/imgCode.action" id="imgCode" onclick="getCode1()">
                <span onclick="getCode1()">看不清？</span><br>
            </div>
            <%--</div>--%>

            <div class="">
                <span class="help-block u-errormessage" id="js-server-helpinfo">&nbsp;</span>			</div>
            <div>

                <input type="button" value="登录" onclick="checkLogin()" class="btn btn-primary" id="button2"/>
                <%--<a href="#">忘记密码?</a>--%>
            </div>
        </form>
    </section>
</div>

</body>
<script>
    function getCode1(){
        var imgCode = document.getElementById("imgCode");
        imgCode.src = "imageAction/imgCode.action?p="+Math.random();
    }

    function checkLogin() {
        if ($("#account").val() == "") {
            alert("用户名不能为空");
            return;
        }
        if ($("#workPwd").val() == "") {
            alert("密码不能为空");
            return;
        }
        var account = $("#account").val();
        var workPwd = $("#workPwd").val();
        var keyCode = $("#keyCode").val();

        $.ajax({
            url : "login/checkLogin.action",
            data : {
                "account" : account,
                "workPwd" : workPwd,
                "keyCode" : keyCode
            },
            type : "post",
            dataType : "text",
            success : function (res) {
                if(res == "success" ){
                    window.alert("登录成功！！");
                    window.location.href="login/login.action";
                }else if(res == "loginError"){
                    window.alert("帐号或密码错误！！")
                    window.location.href="admin_login.jsp";
                }else if(res == "stateError"){
                    window.alert("帐号状态不可用！！")
                }else if(res == "codeError"){
                    window.alert("验证码错误！！")
                }
            }
        });


    }

</script>
</html>